import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
import Inspect from 'vite-plugin-inspect';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Inspect(),
    AutoImport({
      imports: [
        // auto-import 内置 vue vue-router react 常见基本库的引入规则
        //axios lodash
        'vue',
        {
          lodash: [
            // import {concat} from 'lodash'
            'concat',
            // import {compact as cp} from 'lodash'
            ['compact', 'cp'],
          ],
          axios: [
            [
              // import axios from 'axios'
              // import {default as axios } from 'axios'
              'default',
              'axios',
            ],
          ],
        },
      ],
      // 配置本地目录 自动引入
      dirs: ['./src/**'],
      // dirs: ['./src/utils/**'],
    }),
    Components({
      // vue-components 内置了前端主流的resolve element antd
      resolvers: [ElementPlusResolver()],
      // dirs: ['./src/components'], // 默认
      dirs: ['src/components'],
      // 组件名称 包含目录 ，防止命名冲突
      directoryAsNamespaces: true,
      // dirs: ['./src/components', './src/index/components'],
    }),
  ],
  // 以src 为根路径配置 @
  resolve: {
    alias: {
      '@': '/src',
    },
  },
});
